package com.it.App.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.it.App.eneity.Permission;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.Set;

/**
 * @Author: CaoYouGen
 * @DateTime: 2023/11/28/10:42
 * @注释: TODO
 **/
@Mapper
public interface PermissionMapper extends BaseMapper<Permission> {

    @Select("select p.permission_code from user u left join user_role ur on ur.user_id = u.user_id\n" +
            "left join role r on r.role_id = ur.role_id\n" +
            "left join role_permission rp on rp.role_id = r.role_id\n" +
            "left join permission p on p.permission_id = rp.permission_id where u.username = #{username} and p.father_id != 0")
    Set<String> selectAllPermissionCodeByUsername(String username);
}
